package com.ice.work.moment.facade.crawler.mapper;

import com.honeybee.cloud.framework.common.mapper.BaseCovertMapper;
import com.ice.work.moment.facade.crawler.analytical.*;
import com.ice.work.moment.facade.crawler.model.*;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * @Description AnalyticalObjectConvertMapper
 * @Author DELL
 * @Create 2019-01-09
 * @Since 1.0.0
 */
@Mapper
@SuppressWarnings("all")
public interface AnalyticalObjectConvertMapper extends BaseCovertMapper {
    AnalyticalObjectConvertMapper INSTANCE = Mappers.getMapper(AnalyticalObjectConvertMapper.class);


    /**
     * to model
     *
     * @param object
     * @return
     */
    @Mappings({
            @Mapping(target = "recentQuotation", source = "recentQuotation", qualifiedByName = "toLong"),
            @Mapping(target = "priceMovement", source = "priceMovement", qualifiedByName = "toLong"),
            @Mapping(target = "priceMovementRate", source = "priceMovementRate", qualifiedByName = "toLong"),
            @Mapping(target = "yesterdayClosingPrice", source = "yesterdayClosingPrice", qualifiedByName = "toLong"),
            @Mapping(target = "openingPrice", source = "openingPrice", qualifiedByName = "toLong"),
            @Mapping(target = "highestPrice", source = "highestPrice", qualifiedByName = "toLong"),
            @Mapping(target = "bottomPrice", source = "bottomPrice", qualifiedByName = "toLong"),
            @Mapping(target = "turnoverRate", source = "turnoverRate", qualifiedByName = "toLong"),
            @Mapping(target = "tradingAt", source = "tradingAt", qualifiedByName = "toDate"),
            @Mapping(target = "turnover", source = "turnover", qualifiedByName = "toLong"),
            @Mapping(target = "amplitude", source = "amplitude", qualifiedByName = "toLong"),
            @Mapping(target = "volume", source = "volume", qualifiedByName = "toLong")
    })
    Trading toModel(TradingAnalyticalObject object);

    /**
     * to model
     *
     * @param object
     * @return
     */
    Share toModel(ShareAnalyticalObject object);

    /**
     * to model
     *
     * @param object
     * @return
     */
    @Mappings({
            @Mapping(target = "commentAt", source = "commentAt", qualifiedByName = "toDate")
    })
    Comment toModel(CommentAnalyticalObject object);

    /**
     * to model
     *
     * @param object
     * @return
     */
    PositionType toModel(PositionTypeAnalyticalObject object);


    /**
     * to model
     *
     * @param object
     * @return
     */
    @Mappings({
            @Mapping(target = "totalPositionNumber", source = "totalPositionNumber", qualifiedByName = "toLong"),
            @Mapping(target = "positionRate", source = "positionRate", qualifiedByName = "toLong"),
            @Mapping(target = "changePositionNumber", source = "changePositionNumber", qualifiedByName = "toLong"),
            @Mapping(target = "changeRate", source = "changeRate", qualifiedByName = "toLong"),
            @Mapping(target = "closeAt", source = "closeAt", qualifiedByName = "toDate"),
            @Mapping(target = "institutionalNumber", source = "institutionalNumber", qualifiedByName = "toLong")
    })
    InstitutionalPosition toModel(InstitutionalPositionAnalyticalObject object);


    /**
     * to model
     *
     * @param object
     * @return
     */
    @Mappings({
            @Mapping(target = "holdFundNumber", source = "holdFundNumber", qualifiedByName = "toLong"),
            @Mapping(target = "totalPositionNumber", source = "totalPositionNumber", qualifiedByName = "toLong"),
            @Mapping(target = "totalCapitalization", source = "totalCapitalization", qualifiedByName = "toLong"),
            @Mapping(target = "changeHoldFundNumber", source = "changeHoldFundNumber", qualifiedByName = "toLong"),
            @Mapping(target = "closeAt", source = "closeAt", qualifiedByName = "toDate"),
            @Mapping(target = "changeCapitalization", source = "changeCapitalization", qualifiedByName = "toLong"),
            @Mapping(target = "changePositionNumber", source = "changePositionNumber", qualifiedByName = "toLong"),
            @Mapping(target = "preHoldFundNumber", source = "preHoldFundNumber", qualifiedByName = "toLong")
    })
    FundPosition toModel(FundPositionAnalyticalObject object);

}
